Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Refactor R1CS for in-place operations and Vec inputs #121

Merged
merged 1 commit into from
Nov 15, 2023

Conversation

huitseeker
Copy link
Member

@huitseeker huitseeker commented Nov 14, 2023

  • Added a new dependency vecshard version "0.2.1" in the Cargo.toml file.
  • Updated NovaWitness trait method r1cs_instance_and_witness to consume self, impacting its implementation in SatisfyingAssignment.
  • Replaced slicing operations with in-place split for input_assignment using ShardExt trait.
  • Removed unnecessary variable references in R1CSWitness::new and R1CSInstance::new function calls.
  • Refactored new methods in R1CSWitness and R1CSInstance to accept Vec instead of a slice, and removed redundant .to_owned() operation.

This offers one possible alternative for some of the changes in #118

- Added a new dependency `vecshard` version "0.2.1" in the Cargo.toml file.
- Updated `NovaWitness` trait method `r1cs_instance_and_witness` to consume self, impacting its implementation in `SatisfyingAssignment`.
- Replaced slicing operations with in-place split for `input_assignment` using `ShardExt` trait.
- Removed unnecessary variable references in `R1CSWitness::new` and `R1CSInstance::new` function calls.
- Refactored `new` methods in `R1CSWitness` and `R1CSInstance` to accept `Vec` instead of a slice, and removed redundant `.to_owned()` operation.
huitseeker added a commit to argumentcomputer/lurk-beta that referenced this pull request Nov 15, 2023
@huitseeker
Copy link
Member Author

huitseeker commented Nov 15, 2023

Perf impact is minimal,

comparative Nova benches
group                                                        arecibo_avoid_cloning                  arecibo_dev
-----                                                        ---------------------                  -----------
CompressedSNARK-Commitments-StepCircuitSize-0/Prove          1.00       6.6±0.04s            1.01       6.7±0.13s
CompressedSNARK-Commitments-StepCircuitSize-0/Verify         1.01    176.3±3.75ms            1.00    175.2±4.71ms
CompressedSNARK-Commitments-StepCircuitSize-121253/Prove     1.00      17.5±0.35s            1.00      17.4±0.42s
CompressedSNARK-Commitments-StepCircuitSize-121253/Verify    1.05   531.0±18.60ms            1.00   504.1±18.13ms
CompressedSNARK-Commitments-StepCircuitSize-22949/Prove      1.00      10.0±0.14s            1.00       9.9±0.12s
CompressedSNARK-Commitments-StepCircuitSize-22949/Verify     1.00    286.0±7.67ms            1.02   290.6±11.00ms
CompressedSNARK-Commitments-StepCircuitSize-252325/Prove     1.00      30.9±0.28s            1.01      31.2±0.53s
CompressedSNARK-Commitments-StepCircuitSize-252325/Verify    1.07   879.6±53.55ms            1.00   819.2±40.42ms
CompressedSNARK-Commitments-StepCircuitSize-55717/Prove      1.00      16.9±0.34s            1.00      16.9±0.47s
CompressedSNARK-Commitments-StepCircuitSize-55717/Verify     1.02   515.3±17.36ms            1.00    502.9±9.68ms
CompressedSNARK-Commitments-StepCircuitSize-6565/Prove       1.00       9.8±0.18s            1.00       9.8±0.13s
CompressedSNARK-Commitments-StepCircuitSize-6565/Verify      1.01    291.1±8.82ms            1.00    289.4±9.96ms
CompressedSNARK-StepCircuitSize-0/Prove                      1.00   783.9±10.77ms            1.00   787.7±12.18ms
CompressedSNARK-StepCircuitSize-0/Verify                     1.00     31.5±1.47ms            1.00     31.4±0.70ms
CompressedSNARK-StepCircuitSize-1038757/Prove                1.00      47.9±0.79s            1.02      48.8±1.15s
CompressedSNARK-StepCircuitSize-1038757/Verify               1.00  1817.0±47.15ms            1.00  1820.7±40.60ms
CompressedSNARK-StepCircuitSize-121253/Prove                 1.00       6.6±0.18s            1.01       6.6±0.18s
CompressedSNARK-StepCircuitSize-121253/Verify                1.00   230.4±10.78ms            1.04   239.5±14.47ms
CompressedSNARK-StepCircuitSize-22949/Prove                  1.00  1863.6±24.84ms            1.01  1873.9±28.45ms
CompressedSNARK-StepCircuitSize-22949/Verify                 1.02     73.1±3.03ms            1.00     71.6±2.12ms
CompressedSNARK-StepCircuitSize-252325/Prove                 1.00      12.9±0.23s            1.01      13.1±0.31s
CompressedSNARK-StepCircuitSize-252325/Verify                1.00   497.4±16.25ms            1.01   501.4±22.65ms
CompressedSNARK-StepCircuitSize-514469/Prove                 1.00      25.0±0.64s            1.01      25.2±0.79s
CompressedSNARK-StepCircuitSize-514469/Verify                1.03   849.0±38.09ms            1.00   828.1±40.31ms
CompressedSNARK-StepCircuitSize-55717/Prove                  1.00       3.4±0.07s            1.01       3.5±0.07s
CompressedSNARK-StepCircuitSize-55717/Verify                 1.00    124.6±7.33ms            1.00    124.6±5.30ms
CompressedSNARK-StepCircuitSize-6565/Prove                   1.00  1155.8±17.47ms            1.01   1168.3±9.03ms
CompressedSNARK-StepCircuitSize-6565/Verify                  1.00     48.9±2.20ms            1.02     50.0±2.04ms
RecursiveSNARK-StepCircuitSize-0/Prove                       1.00   108.0±12.86ms            1.05    113.0±9.97ms
RecursiveSNARK-StepCircuitSize-0/Verify                      1.00     28.3±0.69ms            1.00     28.2±0.88ms
RecursiveSNARK-StepCircuitSize-1038757/Prove                 1.00  1701.7±60.10ms            1.00  1697.8±63.48ms
RecursiveSNARK-StepCircuitSize-1038757/Verify                1.00  1555.8±40.55ms            1.00  1556.7±31.83ms
RecursiveSNARK-StepCircuitSize-121253/Prove                  1.01   235.1±12.93ms            1.00   232.5±16.72ms
RecursiveSNARK-StepCircuitSize-121253/Verify                 1.04    184.5±7.81ms            1.00    178.0±6.72ms
RecursiveSNARK-StepCircuitSize-22949/Prove                   1.01   120.6±14.70ms            1.00   119.4±11.50ms
RecursiveSNARK-StepCircuitSize-22949/Verify                  1.00     58.5±1.08ms            1.00     58.7±1.62ms
RecursiveSNARK-StepCircuitSize-252325/Prove                  1.00   424.5±18.73ms            1.01   429.9±21.13ms
RecursiveSNARK-StepCircuitSize-252325/Verify                 1.04   388.5±25.24ms            1.00   373.3±30.90ms
RecursiveSNARK-StepCircuitSize-514469/Prove                  1.01   891.2±25.82ms            1.00   880.9±39.69ms
RecursiveSNARK-StepCircuitSize-514469/Verify                 1.03   834.2±32.05ms            1.00   812.5±45.28ms
RecursiveSNARK-StepCircuitSize-55717/Prove                   1.02   156.5±14.27ms            1.00   153.1±10.41ms
RecursiveSNARK-StepCircuitSize-55717/Verify                  1.00     94.5±4.20ms            1.01     95.8±5.68ms
RecursiveSNARK-StepCircuitSize-6565/Prove                    1.00     95.9±6.77ms            1.10   105.7±22.43ms
RecursiveSNARK-StepCircuitSize-6565/Verify                   1.00     36.5±0.52ms            1.00     36.6±0.77ms
Lurk bench: https://github.com/argumentcomputer/lurk-beta/pull/891

@huitseeker huitseeker added this pull request to the merge queue Nov 15, 2023
Merged via the queue into dev with commit fdf8296 Nov 15, 2023
3 checks passed
@huitseeker huitseeker deleted the avoid_cloning branch November 15, 2023 15:45
huitseeker added a commit that referenced this pull request Nov 15, 2023
#121)"

This reverts commit fdf8296.

This should allow us to investigate the effects of components of #118 without noise.
We can re-apply this later if we see it as an improvement.
github-merge-queue bot pushed a commit that referenced this pull request Nov 15, 2023
#121)" (#125)

This reverts commit fdf8296.

This should allow us to investigate the effects of components of #118 without noise.
We can re-apply this later if we see it as an improvement.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants